package edu.towson.cosc603.coffeemaker;

import junit.framework.Assert;
import junit.framework.TestCase;

/**
 *
 */
public class CoffeeMakerTest extends TestCase {
	private CoffeeMaker cm;
	private Inventory i;
	private Recipe r1;

	public void setUp() {
		cm = new CoffeeMaker();
		i = cm.checkInventory();

		r1 = new Recipe();
		r1.setName("Coffee");
		r1.setPrice(50);
		r1.setAmtCoffee(6);
		r1.setAmtMilk(1);
		r1.setAmtSugar(1);
		r1.setAmtChocolate(0);
		
		
		
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setChocolate(int)}.
	 */
	public void testSetChocolateUpperLimit() 
	{
		//all inventory is created with 15 units
		int amtChocolate = 2147483632;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 0;
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = cm.checkInventory();
		int testChocolate = testInventory.getChocolate();
		Assert.assertEquals(2147483647, testChocolate); 
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#getChocolate()}.
	 */
	public void testSetChocolateLowerLimit() 
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 0;
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = cm.checkInventory();
		Assert.assertEquals(15, testInventory.getChocolate()); 
	}
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#getChocolate()}.
	 */
	public void testSetChocolateNegLimit() 
	{
		//all inventory is created with 15 units
		int amtChocolate = -1;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 0;
		
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = cm.checkInventory();
		Assert.assertEquals(15, testInventory.getChocolate()); 
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#getChocolate()}.
	 */
	public void testSetChocolateWithZeroUnits() 
	{
		//all inventory is created with 15 units
		int amtChocolate = -1;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 0;
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = cm.checkInventory();
		Assert.assertEquals(15, testInventory.getChocolate()); 
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setCoffee(int)}.
	 */
	public void testSetCoffeeUpperLimit()
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 2147483632;
		int amtMilk = 0;
		int amtSugar = 0;
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = cm.checkInventory();
		int testCoffee = testInventory.getCoffee();
		Assert.assertEquals(2147483647, testCoffee); 
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setCoffee(int)}.
	 */
	public void testSetCoffeeLowerLimit()
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 0;
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = cm.checkInventory();
		int testCoffee = testInventory.getCoffee();
		Assert.assertEquals(15, testCoffee); 
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setCoffee(int)}.
	 */
	public void testSetCoffeeNegLimit()
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = -1;
		int amtMilk = 0;
		int amtSugar = 0;
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = cm.checkInventory();
		int testCoffee = testInventory.getCoffee();
		Assert.assertEquals(15, testCoffee); 
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setMilk(int)}.
	 */
	public void testSetMilkUpperLimit() 
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = 2147483632;
		int amtSugar = 0;
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = cm.checkInventory();
		int testMilk = testInventory.getMilk();
		Assert.assertEquals(2147483647, testMilk); 
		
		
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setMilk(int)}.
	 */
	public void testSetMilkLowerLimit()
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 0;
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = cm.checkInventory();
		int testMilk = testInventory.getMilk();
		Assert.assertEquals(15, testMilk); 
		
		
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setMilk(int)}.
	 */
	public void testSetMilkNegLimit()
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = -1;
		int amtSugar = 0;
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = cm.checkInventory();
		int testMilk = testInventory.getMilk();
		Assert.assertEquals(15, testMilk); 
		
		
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setSugar(int)}.
	 */
	public void testSetSugarUpperLimit() 
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 2147483632;
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = cm.checkInventory();
		int testSugar = testInventory.getSugar();
		Assert.assertEquals(2147483647, testSugar); 
		
		
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setSugar(int)}.
	 */
	public void testSetSugarLowerLimit()
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 0;
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = cm.checkInventory();
		int testSugar = testInventory.getSugar();
		Assert.assertEquals(15, testSugar); 
		
		
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setSugar(int)}.
	 */
	public void testSetSugarNegLimit()
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = -1;
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = cm.checkInventory();
		int testSugar = testInventory.getSugar();
		Assert.assertEquals(15, testSugar); 
		
		
	}
	
	public void testMakeCoffee1()
	{
		r1.setAmtCoffee(-100);
		int result = cm.makeCoffee(r1,100);
		assertEquals(50,result);
	
	}
	
	public void testMakeCoffee2()
	{
		r1.setAmtChocolate(-100);
		int result = cm.makeCoffee(r1, 100);
		assertEquals(50,result);
	}
	
	public void testMakeCoffee3()
	{
		r1.setAmtSugar(-100);
		int result = cm.makeCoffee(r1, 100);
		assertEquals(50,result);
	}
	
	public void testMakeCoffee4()
	{
		r1.setAmtMilk(-100);
		int result = cm.makeCoffee(r1, 100);
		assertEquals(50,result);
	}
	
	public void testAddRecipe1() {
		assertTrue(cm.addRecipe(r1));
	}

	public void testDeleteRecipe1() {
		cm.addRecipe(r1);
		assertTrue(cm.deleteRecipe(r1));
	}

	public void testEditRecipe1() {
		cm.addRecipe(r1);
		Recipe newRecipe = new Recipe();
		newRecipe = r1;
		newRecipe.setAmtSugar(2);
		assertTrue(cm.editRecipe(r1, newRecipe));
	}
	
	public void testGetRecipes()
	{
		cm.addRecipe(r1);
		Recipe[] arrayRecipes = cm.getRecipes();
		assertEquals(r1,arrayRecipes[3]);
	
	}
	
	public void testGetRecipesForName()
	{
		cm.addRecipe(r1);
		assertEquals(r1,cm.getRecipeForName("Coffee"));
		
		
	}
	
	public void testMakeCoffeeZeroPaid()
	{
		cm.addRecipe(r1);
		int change = cm.makeCoffee(r1, 0);
		assertEquals(0,change);
	}
	
	public void testMakeCoffeeOverPaid()
	{
		cm.addRecipe(r1);
		int change = cm.makeCoffee(r1, 100);
		assertEquals(50,change);
	}
	
	public void testMakeCoffeeUnderPaid()
	{
		cm.addRecipe(r1);
		int change = cm.makeCoffee(r1, 25);
		assertEquals(25,change);
	}
	
	public void testMakeCoffeeNegPaid()
	{
		cm.addRecipe(r1);
		int change = cm.makeCoffee(r1, 0);
		assertEquals(0,change);
	}
	
	
	
}